//
// Created by lzd on 2021/9/8.
//
//利用Horner法则的多项式计算
#include <iostream>
using namespace std;

template <class T>
T Honer(T coeff[], int n, const T& x) {
    T value = coeff[n];
    for (int i = 1; i <= n; i++) {
        value = value * x + coeff[n - i];
    }
    return value;
}

int main() {
    int a[] = {7, 1, -4, 5};
    cout << Honer(a, 3, 2);
    return 0;
}